!% +language_name=3English Constant Story "Heidi"; Constant Headline "^A Simple Inform Example ^Original version by Roger Firth & Sonja Kesserich. ^Ported to Triform by Nathan Schwartzman.^"; ! Notice the new names for the library files. Include "3Parser"; Include "3Verblib"; ! All Rooms are of the class Room. Room before_cottage "In front of a cottage" with description "You stand outside a cottage. The forest stretches east.", e_to forest, in_to "It's such a lovely day -- much too nice to go inside.", cant_go "The only path lies to the east.", has light; ! Anything not standing outside the object tree--floating objects, for ! example--must be a member of the Thing class. ! ! Also, the cottage gives us our introduction to the (adjective) ! property. Compared to alternatives such as Pname.h, covered in the IBG, ! it is simplistic, though this naturally has the advantage of simplicity. Thing -> cottage "tiny cottage" with name "cottage", adjective 'tiny', description "It's small and simple but you're very happy here.", before [; Enter: "It's such a lovely day -- too nice to stay inside."; ], has scenery; Room forest "Deep in the forest" with description "Through the dense foliage you glimpse a building to the west. A track heads to the northeast.", w_to before_cottage, ne_to clearing, has light; Thing -> bird "bird" with name "bird" "nestling", adjective 'baby' 'young' 'little', description "Too young to fly, the nestling tweets helplessly.", before [; Listen: "It sounds scared and in need of assistance."; ]; Room clearing "A forest clearing" with description "A tall sycamore stands in the middle of this clearing. The pathwinds southwest through the trees.", sw_to forest, u_to top_of_tree, has light; ! Because the -container- attribute no longer exists, we make the nest of the ! Container class. Then we set its (inside_capacity) to 1 so that things can be ! put in it. The higher the value of (inside_capacity), the more it can fit. ! We could also have made it a routine, so that its capacity could go up or ! down as the game progressed. Container -> nest "bird's nest" with name "nest" "twigs" "moss", adjective 'bird' 'bird^s', description "The nest is carefully woven of twigs and moss.", inside_capacity 1; ! PlayerTo() no longer exists. Instead, to move the player to a new room-- ! in this case the top of the tree--we call Move(player, top_of_tree, 1). ! And, since the player can't sit or lie down up there, we set her posture to ! 1 (standing) for safety's sake. Thing -> tree "tall Sycamore tree" with name "tree" "sycamore", adjective 'tall' 'proud' 'stout', description "Standing proud in the middle of the clearing, the stout tree looks easy to climb.", before [; Climb: Move(player, top_of_tree, 1); player.posture = 1; rtrue; ], has scenery; ! Here we've added a (before) rule: The player can't attempt to change ! her posture while clinging to the tree. Room top_of_tree "At the top of the tree" with description "You cling precariously to the trunk.", d_to clearing, before [; Sit, Stand, Lie: "You can only cling to the tree."; ], after [; Drop: Move(noun, clearing); "Dropped... to the ground far below."; ], has light; ! Because the -supporter- attribute no longer exists, we make the branch of the ! Container class. Then we set its (ontop_capacity) to 1 so that things can be ! put on it. ! ! Also, we can see that the "deadflag" variable has had its name changed to ! the (perhaps) more intuitive "gameover". Container -> branch "branch" with name "bough" "branch", adjective 'wide' 'flat' 'firm', description "It's flat enough to support a small object.", ontop_capacity 1, each_turn [; if (nest in self && bird in nest) gameover = 2; ], has static; ! Here we can see that the "location" global variable is gone. Instead ! all Things have their own "location" variables. So we have to refer ! to player.location rather than just location. [ Initialise; player.location = before_cottage; player.capacity = 1; ]; Include "3Grammar"; [ ClingSub obj person; if (obj && person) { noun = obj; actor = person; } if (actor in top_of_tree && noun = trunk) "You are!"; if (actor in top_of_tree && noun = branch) "It wouldn't support you."; if (AfterRoutines(noun) == true) rtrue; "There's no reason to do that."; ]; Verb "cling" * 'to' noun -> Cling; end;